package socketmvc.core.lambda;

import socketmvc.core.exception.SockFileIOException;
import socketmvc.core.exception.UnknownException;
import socketmvc.core.exception.SocketMvcBaseException;
import java.io.IOException;

@FunctionalInterface
public interface WrapExceptionSupplier<T> {

    T get() throws Exception;

    static <T> T handleAsCheckedException(WrapExceptionSupplier<T> supplier){
        try {
            return supplier.get();
        }catch (SocketMvcBaseException e) {
            throw e;
        }catch (IOException e){
            throw new SockFileIOException(e);
        }catch (Exception e){
            throw new UnknownException(e);
        }
    }
}
